package com.hanoiwiki.model;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="PLACES")
public class Places extends BaseObject {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="ID")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private String id;
	
	@Column(name="ADDRESS")
	private String address;
	
	@Column(name="STATUS")
	private int status;	
	
	@Column(name="UPDATE_TIME")
	private Date updateTime;
	
	@Column(name="NOTE")
	private String note;
	
	@ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
	private Rates rate;
	
	@OneToMany(mappedBy="places", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	private List<Log> logs;
	
	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name="PLACE_CATEGORY", joinColumns={@JoinColumn(name="PLACE_ID")}
								, inverseJoinColumns={@JoinColumn(name="CAT_ID")})
	private List<Category> categories;
		
		
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}	
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}	
	public String getNote() {
		return note;
	}
	public void setNote(String note) {
		this.note = note;
	}	
	public List<Log> getLogs() {
		return logs;
	}
	public void setLogs(List<Log> logs) {
		this.logs = logs;
	}
	public Rates getRate() {
		return rate;
	}
	public void setRate(Rates rate) {
		this.rate = rate;
	}
	public List<Category> getCategorys() {
		return categories;
	}
	public void setCategorys(List<Category> categories) {
		this.categories = categories;
	}
}